/*! ----------------------------------------------------------------------------
 * @file	port.c
 * @brief	HW specific definitions and functions for portability
 *
 * @attention
 *
 * Copyright 2013 (c) DecaWave Ltd, Dublin, Ireland.
 *
 * All rights reserved.
 *
 * @author DecaWave
 */
#include "deca_sleep.h"
#include "port.h"


/******************
@function:RCC_Configuration()
@description:rcc bus configure.
@parameter:
none
*******************/
int RCC_Configuration(void)
{
	return 0;
}

/******************
@function:SPI_ChangeRate()
@description:set spi speed.
@parameter:
scalingfactor:the parameter of the spi speed.
*******************/
void SPI_ChangeRate(uint16_t scalingfactor)
{
	uint16_t tmpreg = 0;

	/* Get the SPIx CR1 value */
	tmpreg = SPIx->CR1;

	/*clear the scaling bits*/
	tmpreg &= 0xFFC7;

	/*set the scaling bits*/
	tmpreg |= scalingfactor;

	/* Write to SPIx CR1 */
	SPIx->CR1 = tmpreg;
}

/******************
@function:spi_set_rate_low()
@description:set spi in the low speed.
@parameter:
none
*******************/
void spi_set_rate_low (void)
{

}

/******************
@function:spi_set_rate_high()
@description:set spi in the high speed.
@parameter:
none
*******************/
void spi_set_rate_high (void)
{

}

/******************
@function:SPI_ConfigFastRate()
@description:configure the spi speed
@parameter:
scalingfactor:the parameter of the spi speed.
*******************/
void SPI_ConfigFastRate(uint16_t scalingfactor)
{
}

/******************
@function:SPI_Configuration()
@description:the dwm1000 spi configuration.
@parameter:
	None  
*******************/ 
int SPI_Configuration(void)
{
	return 0;
}


void Reset_DW1000(void)
{
	HAL_GPIO_WritePin(DW1000_RSTn_GPIO,DW1000_RSTn,GPIO_PIN_RESET);
	HAL_Delay(5);
	HAL_GPIO_WritePin(DW1000_RSTn_GPIO,DW1000_RSTn,GPIO_PIN_SET);
}


/******************
@function:dwm1000_peripherals_init()
@description:the dwm1000 peripherals initial.
@parameter:
	None  
*******************/  
void dwm1000_peripherals_init (void)
{

}
